<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>菜单列表</title>
</head>
<body>
<div class="layui-fluid">
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
        <legend>菜单列表</legend>
    </fieldset>
    <#if menus?? && (menus?size > 0)>
        <#list menus as menu>
            <div class="layui-collapse" lay-filter="test">
                <div class="layui-colla-item">
                    <h2  class="layui-colla-title">
                        名称：${menu.menu}
                        <span style="margin-left: 10%;margin-right: 10%;">
                             <#if menu.rootName??>
                                 权限：${menu.rootName}
                             <#else>
                                 <span>暂无权限</span>
                             </#if>
                        </span>
                        URL：${menu.url}
                        <div class="layui-btn-group" style="float: right;">
                            <div class="layui-btn-container">
                                <a class="layui-btn layui-btn-radius layui-btn-normal layui-btn-sm updateMenuBtn" menuId="${menu.id}"
                                   menuName="${menu.menu}" menuUrl="${menu.url}" rootId="${menu.rootId}">
                                    <i class="layui-icon">&#xe642;</i>
                                </a>
                                <#if menu.itemmenus?? && (menu.itemmenus?size > 0)>
                                <#else>
                                    <a class="layui-btn layui-btn-primary layui-btn-sm deleteMenuBtn" menuId="${menu.id}">
                                        <i class="layui-icon">&#xe640;</i>
                                    </a>
                                </#if>
                            </div>
                        </div>
                    </h2>
                    <#if menu_index == 0>
                    <div class="layui-colla-content layui-show">
                    <#else>
                    <div class="layui-colla-content">
                    </#if>
                        <#if menu.itemmenus?? && (menu.itemmenus?size > 0)>
                            <table class="layui-table" lay-even="" lay-skin="nob" style="width: 80%;">
                                <colgroup>
                                    <col width="6%">
                                    <col width="20%">
                                    <col width="20%">
                                    <col width="30%">
                                    <col>
                                </colgroup>
                                <thead>
                                <tr>
                                    <th>序号</th>
                                    <th>子菜单</th>
                                    <th>权限</th>
                                    <th>URL</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                    <#list menu.itemmenus as itemMenu>
                                        <tr>
                                            <td>${itemMenu_index+1}</td>
                                            <td>${itemMenu.menu}</td>
                                            <td>
                                                <#if itemMenu.rootName??>
                                                    ${itemMenu.rootName}
                                                <#else>
                                                    <span>暂无权限</span>
                                                </#if>
                                            </td>
                                            <td>${itemMenu.url}</td>
                                            <td>
                                                <div class="layui-btn-group">
                                                    <a class="layui-btn layui-btn-sm updateItemMenu" menuId="${itemMenu.id}"
                                                       menuName="${itemMenu.menu}" menuUrl="${itemMenu.url}" rootId="${itemMenu.rootId}" parentId="${itemMenu.pid}" ><i class="layui-icon">&#xe642;</i></a>
                                                    <a class="layui-btn layui-btn-sm deleteItemMenu" menuId="${itemMenu.id}" ><i class="layui-icon">&#xe640;</i></a>
                                                </div>
                                            </td>
                                        </tr>
                                    </#list>
                                </tbody>
                            </table>
                        <#else>
                            <p>暂无子菜单</p>
                        </#if>
                    </div>
                </div>
            </div>
        </#list>
    </#if>
</div>

<div id="updateMenuView" class="layui-fluid" hidden>
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
        <legend id="fieldTitle">修改菜单</legend>
    </fieldset>
    <form class="layui-form" action="">
        <div class="layui-form-item">
            <label class="layui-form-label">菜单名</label>
            <div class="layui-input-block" style="margin-right: 5%">
                <input type="text" name="menuName" id="menuName" required  lay-verify="required" placeholder="请输入菜单名" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" >URL</label>
            <div class="layui-input-block" style="margin-right: 5%">
                <input type="text" name="menuUrl" id="menuUrl" required  lay-verify="required" placeholder="请输入URL" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item" hidden>
            <label class="layui-form-label">父级菜单</label>
            <div class="layui-input-block" style="margin-right: 5%">
                <select id="parentMenu" name="parentMenu" lay-verify="required">
                <#list menus as menu>
                    <option value="${menu.id}">${menu.menu}</option>
                </#list>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">权限</label>
            <div class="layui-input-block" style="margin-right: 5%">
                <select id="myroot" name="myroot" lay-verify="required">
                    <option value="0">无权限</option>
                    <#list roots as root>
                        <option value="${root.id}">${root.descript}</option>
                    </#list>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <a class="layui-btn" id="updateMenuBtn">确认修改</a>
                <a class="layui-btn layui-btn-primary" id="resetMenuBtn">重置</a>
            </div>
        </div>
    </form>
</div>

</body>
</html>